<?php

declare(strict_types=1);

namespace App\Command;

use App\Services\HttpService;
use Hyperf\Command\Command as HyperfCommand;
use Hyperf\Command\Annotation\Command;
use Psr\Container\ContainerInterface;

/**
 * @Command
 */
class HttpClient extends HyperfCommand
{
    /**
     * @var ContainerInterface
     */
    protected $container;

    protected $httpClient;

    public function __construct(ContainerInterface $container, HttpService $httpService)
    {
        $this->container = $container;

        $this->httpClient = $httpService;

        parent::__construct('http:client');
    }

    public function configure()
    {
        parent::configure();
        $this->setDescription('Hyperf Demo Command');
    }

    public function handle()
    {
        $res = $this->httpClient->get('http://127.0.0.1:9501');
        var_dump($res);
        $this->line('Hello Hyperf!', 'info');
    }
}
